package main

import (
	"github.com/gin-contrib/cors"
	"github.com/gin-gonic/gin"
	log "github.com/sirupsen/logrus"
	"vmService/vmservice/tgt"
	"vmService/vmservice/vm"
)

//var db = make(map[string]string)

func setupRouter() *gin.Engine {
	// Disable Console Color
	// gin.DisableConsoleColor()
	vms := vm.VirtualMachineServices{}
	r := gin.Default()
	r.Use(cors.Default())

	r.GET("/listpods", vms.ListPods)
	r.GET("/listdatavolume", vms.ListDataVolumes)
	r.GET("/listpvcevents", vms.ListPVCEvents)
	r.GET("/listresizingpvc", vms.ListResizingPVC)
	r.GET("/listhosts", vms.ListHosts)
	r.GET("/minio", vms.MinioLogin)
	r.POST("/createdatavolume", vms.CreateDataVolume)
	r.POST("/deletedatavolume", vms.DeleteDataVolume)
	r.POST("/expanddatavolume", vms.ExpandDataVolume)
	r.POST("/harvester/api", vms.HarvesterApi)

	r.POST("/tgt/gateway/manager", tgt.ManagerTgtService)
	r.POST("/tgt/gateway/status", tgt.ShowTgtStatus)
	r.GET("/tgt/gateway/list", tgt.GetTgtList)

	r.POST("/tgt/target/manager", tgt.ManagerTarget)
	r.POST("/tgt/target/list", tgt.GetTargetList)
	r.POST("/tgt/target/ip", tgt.BindTargetIP)
	r.POST("/tgt/target/ip/list", tgt.GetTargetIPList)
	r.POST("/tgt/target/user", tgt.BindTargetUser)
	r.POST("/tgt/target/user/list", tgt.GetTargetUserList)
	r.POST("/tgt/target/lun", tgt.AddLUN)
	r.POST("/tgt/target/lun/list", tgt.GetTargetLUNList)
	//r.POST("/tgt/uninstall", tgt.)

	r.GET("/tgt/")

	r.GET("/db/test", tgt.TestDB)
	return r
}

func main() {
	//gin.SetMode(gin.ReleaseMode)
	gin.SetMode(gin.DebugMode)
	r := setupRouter()
	log.SetLevel(log.DebugLevel)
	//r.Use(cors.Default())
	// Listen and Server in 0.0.0.0:8080
	r.Run(":5002")
}
